#ifndef _NE_ANIMATION_GROUP_H_
#define _NE_ANIMATION_GROUP_H_

#include <system/ResourceManager.h>
#include <animation/Animation.h>

namespace ne
{
    class NEAPI AnimationGroup : public Resource, public ResourceManager
    {
        public:
            AnimationGroup(ResourceManager *pManager,
                           const uint64_t id,
                           const std::string &name,
                           const std::string &fileName,
                           const bool isManual,
                           ManualResourceLoader *pLoader);

            virtual ResourcePtr prepare(const std::string &name,
                                        const std::string &fileName,
                                        const bool isManual=false,
                                        ManualResourceLoader *pLoader=0,
                                        const bool backgroundThread=false);

            virtual ResourcePtr load(const std::string &name,
                                     const std::string &fileName,
                                     const bool isManual=false,
                                     ManualResourceLoader *pLoader=0,
                                     const bool backgroundThread=false);

            virtual bool prepare(const bool backgroundThread=false);
            
            virtual bool load(const bool backgroundThread=false);

            void optimise(const bool discardIdentityNodeTracks=true);

            virtual ~AnimationGroup();

        protected:
            virtual bool loadImplement();

            virtual bool unloadImplement();

            virtual bool downloadImplement();

            virtual size_t _calculateSize() const;

        protected:
            Resource* createImplement(const uint64_t id,
                                      const std::string &name,
                                      const std::string &fileName,
                                      const bool isManual,
                                      ManualResourceLoader *pLoader);
    };

    class NEAPI AnimationGroupPtr : public SharedPtr<AnimationGroup>
    {
        public:
            AnimationGroupPtr() : SharedPtr<AnimationGroup>() {}
            explicit AnimationGroupPtr(AnimationGroup *pAnimationGroup) : SharedPtr<AnimationGroup>(pAnimationGroup) {}
            AnimationGroupPtr(const AnimationGroupPtr &pAnimationGroup) : SharedPtr<AnimationGroup>(pAnimationGroup) {}

            AnimationGroupPtr(const ResourcePtr &p)
                : SharedPtr<AnimationGroup>()
            {
                mpPtr = static_cast<AnimationGroup*>(p.ptr());
                mpUseCount = p.getUseCountPtr();
                if (mpUseCount)
                {
                    ++(*mpUseCount);
                }
            }

            AnimationGroupPtr& operator = (const ResourcePtr &p)
            {
                if (mpPtr == static_cast<AnimationGroup*>(p.ptr()))
                {
                    return *this;
                }
                AnimationGroupPtr temp(p);
                swap(temp);
                return *this;
            }
    };
}

#endif

